package config

import (
    "encoding/json"
    "io/ioutil"
)

const (
    WX_MP string = "MP"
    WX_CP string = "CP"
)

type WxConfig struct {
    AppId  string
    AppSec string
    WxType string
}

type ServerConfig struct {
    Port   int
    Host   string
    Config map[string]WxConfig
}

func LoadConfig(filePath string) (ServerConfig, error) {
    var buf []byte
    var err error
    var config ServerConfig
    buf, err = ioutil.ReadFile(filePath)
    if err != nil {
        return config, err
    }

    jsonstr := string(buf)

    err = json.Unmarshal([]byte(jsonstr), &config)
    if err != nil {
        return config, err
    }
    return config, nil
}
